package com.hjc.springbootmovies.controller;

import com.hjc.springbootmovies.entity.ModelFiml;
import com.hjc.springbootmovies.service.Impl.FimlServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created by IntelliJ IDEA.
 * User: HJC
 * Date: 2019/12/4
 * Time: 14:34
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("/fiml")
public class FimlController {
    @Autowired
    private FimlServiceImpl fimlService;

    @GetMapping("fimlControllerAll")
    public String fimlAll(){
        return "html/firm/all";
    }

    @GetMapping("fimlControllerAdd")
    public String fimlAdd(){
        return "html/firm/add";
    }

    @GetMapping("fimlControllerUpdate")
    public String fimlUpdate(int fid , Model model){
        model.addAttribute("update" , fimlService.queryById(fid));
        return "html/firm/update";
    }

    @GetMapping("fimlControllerShang")
    public String fimlShang(){
        return "html/firm/shang";
    }

    @RequestMapping( value = "addFiml" , method = RequestMethod.POST)
    String addFiml(ModelFiml modelFiml){
        int count = fimlService.addFiml(modelFiml);
        return "html/firm/all";
    }

    @RequestMapping( value = "deleteById" , method = RequestMethod.GET)
    String deleteById(Integer fid,Integer fflag){
        int count = fimlService.deleteById(fid,fflag);
        return "html/firm/all";
    }

    @RequestMapping( value = "updateFiml" , method = RequestMethod.POST)
    String updateFiml(ModelFiml modelFiml){
        int count = fimlService.updateFiml(modelFiml);
        return "html/firm/all";
    }

}
